<%@page import="com.tofindaway.entity.Reply"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page
	import="com.tofindaway.entity.Article,
	com.tofindaway.service.UserServ,
	org.springframework.web.context.WebApplicationContext,
	org.springframework.web.context.ContextLoader,
	java.util.List,java.util.ArrayList"%>
<%
	Long id = 0l;
	String err = "";
	try {
		id = Long.parseLong(request.getParameter("id"));
		System.out.println("get id is :" + id);
	} catch (Exception e) {
		e.printStackTrace();
	}
	WebApplicationContext context = ContextLoader
			.getCurrentWebApplicationContext();
	UserServ userServ = (UserServ) context.getBean("userServ");
	Article article = null;
	Set<Reply> replys = null;
	try {
		article = userServ.findArticleById(id);
		if (article != null) {
			replys = article.getReplaySet();
		}
	} catch (Exception e) {
		err = "<strong>服务器出现异常。请稍后再试。</strong>" + e.toString();
		System.out.println(e);
	}
%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/blog/css/main.css" />
<link rel="stylesheet" type="text/css" href="./css/article.css" />
<title>愿生如夏花之绚烂 2012</title>
</head>
<body>
	<%@ include file="/include/nav.jsp"%>
	<div style="height: 50px;"></div>
	<%
		if (article != null) {
	%>
	<div class="article">
		<div class="title">
			<%
				out.println(article.getTitle());
			%>
		</div>
		<div class="time">
			<ul>
				<li>作者:<%
					out.print(article.getUser().getNickname());
				%></li>
				<li>发表时间:<%
					out.println(article.getCreated());
				%></li>
			</ul>
		</div>
		<div class="content">
			<%
				out.println(article.getContent());
			%>
		</div>
		<div class="tags">
			<a href="#">tags:<%
				out.println(article.getTag());
			%></a>
		</div>
	</div>
	<div style="height: 50px;"></div>
	<div id="reply_number">
		共
		<%
		out.println(article.getReplaySet().size());
	%>
		条评论关于 :
		<%
		out.println(article.getTitle());
	%>
	</div>
	<%
		if (replys != null) {
				for (Reply reply : replys) {
	%>
	<div id="reply">
		<div class="person">
			<xmp> <%
 	out.print(reply.getName());
 %> </xmp>
		</div>
		<div class="time">
			<%
				out.print(reply.getCreated());
			%>
		</div>
		<div class="reply_content">
			<xmp> <%
 	out.print(reply.getContent());
 %> </xmp>
		</div>
		<div class="reply_reply">
			<a>回复</a>
		</div>
	</div>
	<%
		}
			}
		} else {
	%>
	<div class="article">
		<div class="content">
			<%
				out.println(err);
			%>
		</div>
	</div>
	<%
		}
	%>
</body>
</html>